﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;

namespace Common
{
    public class ConnectionFactory
    {
        private static readonly string connectionName = ConfigurationManager.AppSettings["ConnectionName"];
        private static readonly string connString = ConfigurationManager.ConnectionStrings["DBContextWeb"].ConnectionString;
        public static IDbConnection CreateConnectionWebDB()
        {
            IDbConnection conn = null;
            conn = new SqlConnection(connString);
            conn.Open();
            return conn;
        }

        public static IDbConnection CreateConnection()
        {
            IDbConnection conn = null;
            switch (connectionName)
            {
                case "SQLServer":
                    conn = new SqlConnection(connString);
                    break;
                case "MySQL":
                    // conn = new MySqlConnection(connString);
                    break;
                default:
                    conn = new SqlConnection(connString);
                    break;
            }
            conn.Open();
            return conn;
        }
    }
}
